/*
 * @lc app=leetcode.cn id=1827 lang=typescript
 *
 * [1827] 最少操作使数组递增
 */

// @lc code=start
function minOperations(nums: number[]): number {
    let count = 0;
    for (let i = 1; i < nums.length; i++) {
        const prev = nums[i - 1];
        const element = nums[i];
        if (element > prev) {
            continue;
        } else {
            count += prev - element + 1;
            nums[i] = prev + 1;
        }
    }
    return count;
}
// @lc code=end
